package customer.ejb.eaos;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import customer.ejb.eaos.PredefinedTPOffer;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import model.PredefinedTP;
import common.OperationCallback;
import dtos.PredefinedTPDTO;


@Stateless
public class PredefinedTPOfferEAO implements PredefinedTPOffer{
	
	@PersistenceContext
    private EntityManager em;
	
	public PredefinedTPOfferEAO(){
		
	}

	@Override
	public void add(PredefinedTPDTO predefinedTPDTO) {
		em.persist(new PredefinedTP(predefinedTPDTO));
		
	}

	@Override
	public Collection<PredefinedTPDTO> getPredefinedTPOffer() {
		@SuppressWarnings("unchecked")
		List<PredefinedTP> qres = em.createQuery("SELECT p FROM PredefinedTP p").getResultList();
		Collection<PredefinedTPDTO> res = new ArrayList<PredefinedTPDTO>(qres.size());
		for(PredefinedTP e : qres)
		{
			res.add(e.getDTO());
		}
		return res;
	}

	@Override
	public PredefinedTPDTO getPredefinedTP(int id) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void savePackage(PredefinedTPDTO p, OperationCallback oc) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void removePackage(PredefinedTPDTO p, OperationCallback oc) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void updatePackage(PredefinedTPDTO pkg, OperationCallback oc) {
		// TODO Auto-generated method stub
		
	}
	
	
	


}
